$(document).ready(function () {
    // 友情链接数据
    const friendLinks = [
        { date: '2025-06-13', blogName: '脑电波鸦鸦的巢穴', title: '' },
        { date: '2025-05-31', blogName: '贰伍，伍ZTGD的小窝', title: '' },
        { date: '2025-05-29', blogName: '脑电波鸦鸦的巢穴', title: '' },
        { date: '2025-05-29', blogName: '脑电波鸦鸦的巢穴', title: '' },
        { date: '2025-05-23', blogName: '一时有感写写关于227ZTGD的小窝', title: '' },
        { date: '2025-05-11', blogName: 'argon-template-linksZTGD的小窝', title: '' },
        { date: '2025-05-09', blogName: '博客方案整理ZTGD的小窝', title: '' },
        { date: '2025-05-08', blogName: '餌食の本懐 第一部分ZTGD的小窝', title: '' },
        { date: '2025-03-29', blogName: '勇敢者先享受世界并非正文', title: '' },
        { date: '2025-03-21', blogName: '闲置的小米Note3安装Ubuntu+宝塔+DDNS-GO并非正文', title: '' },
        { date: '2025-02-18', blogName: '实习小记Echo小窝', title: '' },
        { date: '2025-02-12', blogName: '记小米Note3安装ArchLinux并非正文', title: '' },
        { date: '2025-01-21', blogName: 'NAS入坑笔记 | 网盘+相册+影视库+软路由 ALL IN ONE鸦鸦的巢穴', title: '' },
        { date: '2025-01-02', blogName: '2024年终总结Echo小窝', title: '' },
        { date: '2024-12-29', blogName: '迄今为止最满意的GIF录屏软件鸦鸦的巢穴', title: '' },
        { date: '2024-12-09', blogName: '1分钟能解决的事情被硬控10分钟并非正文', title: '' },
        { date: '2024-12-08', blogName: '自制仿霓虹灯形式的SVG动画并非正文', title: '' },
        { date: '2024-07-11', blogName: '记第一次被DDOS的经历PandaX Blog', title: '' },
        { date: '2024-01-07', blogName: '2023年终总结Echo小窝', title: '' },
        { date: '2023-12-21', blogName: 'Git命令汇总Echo小窝', title: '' },
        { date: '2023-11-29', blogName: '记一次群晖服务器严重宕机事件PandaX Blog', title: '' },
        { date: '2023-11-29', blogName: '大学物理下期末复习总结PandaX Blog', title: '' },
        { date: '2023-11-25', blogName: '讯飞免费星火大模型部署教程Echo小窝', title: '' },
        { date: '2023-09-23', blogName: '程序的执行和模拟器–学习笔记PandaX Blog', title: '' },
        { date: '2023-09-21', blogName: '从C语言到二进制–学习笔记PandaX Blog', title: '' }
    ];

    // 渲染友情链接
    const renderFriendLinks = () => {
        const friendsList = $('#friendsList');
        friendsList.empty();

        friendLinks.forEach(link => {
            const friendItem = $('<div>').addClass('friend-item');
            const dateSpan = $('<span>').addClass('friend-date').text(link.date);
            const blogNameLink = $('<a>').addClass('friend-blog-name').text(link.blogName).attr('href', '#').attr('target', '_blank');
            const titleSpan = link.title ? $('<span>').addClass('friend-title').text(link.title) : null;

            friendItem.append(dateSpan).append(blogNameLink);
            if (titleSpan) friendItem.append(titleSpan);
            friendsList.append(friendItem);
        });
    };

    // 初始化渲染
    renderFriendLinks();

    // 友情链接展开/折叠功能
    $('#friendToggle').click(function () {
        const friendsList = $('#friendsList');
        const isExpanded = friendsList.css('display') !== 'none';
        friendsList.toggle();
        $(this).find('.toggle-icon').text(isExpanded ? '+' : '-');
    });
});